package Principal;

import java.io.File;
import java.io.IOException;

import GameOfLife.Game;

public class TestMultiJeu {

	public static void MultiJeu(File repertoire) throws IOException {

		traitement(repertoire.getAbsolutePath());
		
		if (repertoire.isDirectory()) {
			File[] list = repertoire.listFiles();
			
			if (list != null) {
				for (File f : list) {
					if (!f.isHidden()) {
						MultiJeu(f);
					}
				}
			} else {
				System.err.println(repertoire + " : Erreur de lecture.");
			}
		}
	}
	
	
	
	private static void traitement(String absolutePath) {
		
		Game game;
		String tmp[] = absolutePath.split("/");
		String name = tmp[tmp.length-1];
		
		if(testLIF(name)) {
			game = new Game(name);
			System.out.println(game);
		} else {
			System.out.println("erreur test");
		}
		
	}



	private static boolean testLIF(String name) {

		String tmp[] = name.split("\\.");

		if(tmp.length != 2) {
			return false;
		} else if(!tmp[1].equals("LIF")) {
			return false;
		}
		
		return true;
	}



	public static void main(String[] args) {
		try {
			MultiJeu(new File("LIF"));
		} catch (IOException e) {
			System.err.println("Erreur répertoire");
		}
	}

}
